/**
 * Author:   YASUO
 * Date:     2018/7/11 13:55
 * Description: 能量类型常量
 */
package com.rljk.common.consts;

import com.rljk.common.result.CodeMsg;
import com.rljk.exception.GlobalException;

/**
 * 能量
 */
public enum EnergyEnum {

    INVITATION(1,"邀请",100),
    DAY_SIGN(2,"签到",2),
    FOLLOW_WECHAT(3,"关注微信公众号",5),
    SHOPPING(4,"购物",10),
    LOGIN(5,"登录",10)
    ;

    private int code;
    private String name;
    private double socre;

    EnergyEnum(int code, String name,double socre) {
        this.code = code;
        this.name = name;
        this.socre = socre;
    }


    public static String getName(int code) {
        for (EnergyEnum c : EnergyEnum.values()) {
            if (c.getCode() == code) {
                return c.name;
            }
        }
        throw new GlobalException(CodeMsg.ENUM_NOT_FIND);
    }

    public static double getScore(int code) {
        for (EnergyEnum c : EnergyEnum.values()) {
            if (c.getCode() == code) {
                return c.getSocre();
            }
        }
        throw new GlobalException(CodeMsg.ENUM_NOT_FIND);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public double getSocre() {
        return socre;
    }

    public void setSocre(double socre) {
        this.socre = socre;
    }
}
